var __extends =
    (this && this.__extends) ||
    (function () {
      var e = function (t, i) {
        return (e =
          Object.setPrototypeOf ||
          ({ __proto__: [] } instanceof Array &&
            function (e, t) {
              e.__proto__ = t;
            }) ||
          function (e, t) {
            for (var i in t)
              Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i]);
          })(t, i);
      };
      return function (t, i) {
        function n() {
          this.constructor = t;
        }
        if ("function" != typeof i && null !== i)
          throw new TypeError(
            "Class extends value " + String(i) + " is not a constructor or null"
          );
        e(t, i),
          (t.prototype =
            null === i
              ? Object.create(i)
              : ((n.prototype = i.prototype), new n()));
      };
    })(),
  AXEnjoyPlaceView = (function (e) {
    function t() {
      var t = e.call(this) || this;
      return (
        (t.caiquanArr = []),
        (t.enjoyLoadCoinFn = {
          caller: t,
          code: 1451,
          method: function (e) {
            0 == e.code
              ? ((t.lbl_carry_gold.text = e.data.gold),
                (t.lbl_carry_slider.text = e.data.money))
              : ToastView.toastView(e.msg);
          },
        }),
        (t.enjoySanGuoyaFn = {
          caller: t,
          code: 4430,
          method: function (e) {
            0 == e.code &&
              ((t.lbl_sanguotitle.text = "第 " + e.data.curRndNum + " 回合"),
              t.preSanGuoID != e.data.curRndNum &&
                ((t.lbl_wei_sumgold.text = "0 金"),
                (t.lbl_wei_sumsliver.text = "0 银"),
                (t.lbl_shu_sumgold.text = "0 金"),
                (t.lbl_shu_sumsliver.text = "0 银"),
                (t.lbl_wu_sumgold.text = "0 金"),
                (t.lbl_wu_sumsliver.text = "0 银"),
                (t.lbl_wei_mygold.text = "0 金"),
                (t.lbl_wei_mysliver.text = "0 银"),
                (t.lbl_wu_mygold.text = "0 金"),
                (t.lbl_wu_mysliver.text = "0 银"),
                (t.lbl_shu_mygold.text = "0 金"),
                (t.lbl_shu_mysliver.text = "0 银"),
                (t.preSanGuoID = e.data.curRndNum)),
              (t.lbl_sanguodescr.text = e.data.reportStr),
              0 == e.code && e.data.list && t.initSanGuoDesktopView(e.data),
              (t.sanguoTimeDiff = parseInt(e.data.second)),
              Laya.timer.loop(1e3, t, t.timerCountDownSanguoFn));
          },
        }),
        (t.enjoySanGuoyaZhiYuanFn = {
          caller: t,
          code: 4437,
          method: function (e) {
            ToastView.toastView(e.msg),
              8 == e.code ||
                WebSocketService.send({ c: 4430, d: { pageNum: 0 } });
          },
        }),
        (t.enjoyCaiquanActionFn = {
          caller: t,
          code: 2110,
          method: function (e) {
            GuessPapersView.close(),
              ToastView.toastView(e.msg),
              WebSocketService.send({ c: 2103, d: { pageNum: 0 } });
          },
        }),
        (t.enjoyCaiquanAcceptFn = {
          caller: t,
          code: 2111,
          method: function (e) {
            0 == e.code
              ? (1 == e.data
                  ? ToastView.toastView("对不起，您输了！")
                  : 2 == e.data
                  ? ToastView.toastView("恭喜您，您赢了！")
                  : 3 == e.data && ToastView.toastView("恭喜您，平局！"),
                WebSocketService.send({ c: 2103, d: { pageNum: 0 } }))
              : ToastView.toastView(e.msg);
          },
        }),
        (t.enjoyCaiQuanYaFn = {
          caller: t,
          code: 2103,
          method: function (e) {
            var i = e.list;
            i.length > 0 && (t.list_caiquan.visible = !0), (t.caiquanArr = []);
            for (var n, a = 0; a < i.length; a++)
              (n = {
                caiquanItem: {
                  text:
                    i[a].name +
                    "发起挑战，下注" +
                    i[a].bet +
                    t.dealCaiQuanYaMoneryCell(i[a].type),
                },
                jieshoutiaozhan: { label: "挑战" },
                figID: i[a].id,
                figTitle: i[a].bet,
                othName: i[a].name,
                userID: i[a].userId,
              }),
                t.caiquanArr.push(n);
            t.list_caiquan.array = t.caiquanArr;
          },
        }),
        (t.enjoyYuLeChangFn = {
          caller: t,
          code: 1332,
          method: function (e) {
            if (0 == e.code) {
              var i = e.data;
              t.resultArr = e.data;
              var n = i.prenum1,
                a = i.prenum2,
                o = i.prenum3;
              void 0 == t.lastBaGuaId && (t.lastBaGuaId = e.data.id),
                t.timeDiff <= 0 &&
                  t.countRoundV &&
                  (console.log(
                    "this.lastBaGuaId ================================ " +
                      t.lastBaGuaId +
                      "      msg.data.id ++++++++++++++++++= " +
                      e.data.id
                  ),
                  t.lastBaGuaId != e.data.id &&
                    (t.countRoundV.showRoundResult(n, a, o),
                    (t.lastBaGuaId = e.data.id)));
              var l = Utils.dealCompentResult(n, a, o),
                s = 0;
              i.id > 0 && (s = i.id - 1),
                (t.pastRecordsLab.text =
                  "上期 ( " +
                  s +
                  " ) 开 " +
                  t.dealPerNumToBaGua(n) +
                  " , " +
                  t.dealPerNumToBaGua(a) +
                  " , " +
                  t.dealPerNumToBaGua(o) +
                  " " +
                  l),
                t.initCaiCaiDesktopView(i),
                (t.timeDiff = Math.floor(e.data.second)),
                Laya.timer.loop(1e3, t, t.timerCountDownFn);
            }
          },
        }),
        (t.enjoyGambleActionFn = {
          caller: t,
          code: 1336,
          method: function (e) {
            ToastView.toastView(e.msg),
              0 == e.code &&
                (WebSocketService.send({ c: 1332, d: null }),
                WebSocketService.send({ c: 1451, d: null }));
          },
        }),
        t.btn_back_enjoy.on(Laya.Event.CLICK, t, t.onEnjoyPlaceBackFn),
        t.btn_historyRecord.on(Laya.Event.CLICK, t, t.onEnjoyCommonDidClickFn),
        t.btn_bettingRecord.on(Laya.Event.CLICK, t, t.onEnjoyCommonDidClickFn),
        t.btn_rewardList.on(Laya.Event.CLICK, t, t.onEnjoyCommonDidClickFn),
        t.btn_gameRule.on(Laya.Event.CLICK, t, t.onEnjoyCommonDidClickFn),
        t.btn_pochanshenqing.on(Laya.Event.CLICK, t, t.onPoChanShenQingFn),
        t.btn_ccywinnerList.on(Laya.Event.CLICK, t, t.onEnjoyCommonDidClickFn),
        t.btn_big.on(Laya.Event.CLICK, t, t.onBigDidClick),
        t.btn_small.on(Laya.Event.CLICK, t, t.onSmallDidClick),
        t.btn_single.on(Laya.Event.CLICK, t, t.onSingleDidClick),
        t.btn_double.on(Laya.Event.CLICK, t, t.onDoubleDidClick),
        t.btn_leopard.on(Laya.Event.CLICK, t, t.onLeopardDidClick),
        t.btn_shangqian.on(Laya.Event.CLICK, t, t.onShangQianDidClick),
        t.btn_weiguo.on(Laya.Event.CLICK, t, t.onsupportDidClickFn),
        t.btn_shuguo.on(Laya.Event.CLICK, t, t.onsupportDidClickFn),
        t.btn_wuguo.on(Laya.Event.CLICK, t, t.onsupportDidClickFn),
        t.btn_throwChallenge.on(Laya.Event.CLICK, t, t.onThrowChallengeFn),
        t.list_caiquan.on(Laya.Event.CLICK, t, t.setCaiQuanSelected),
        (t.list_caiquan.vScrollBarSkin = ""),
        (t.tab_enjoy.selectHandler = new Laya.Handler(
          t,
          t.onSelectEnjoyHandleFn
        )),
        WebSocketService.addListener(t.enjoyYuLeChangFn),
        WebSocketService.addListener(t.enjoyGambleActionFn),
        WebSocketService.addListener(t.enjoySanGuoyaFn),
        WebSocketService.addListener(t.enjoySanGuoyaZhiYuanFn),
        WebSocketService.addListener(t.enjoyCaiQuanYaFn),
        WebSocketService.addListener(t.enjoyCaiquanActionFn),
        WebSocketService.addListener(t.enjoyCaiquanAcceptFn),
        WebSocketService.addListener(t.enjoyLoadCoinFn),
        t
      );
    }
    return (
      __extends(t, e),
      (t.openView = function () {
        return (
          null == this.enjoyPlaceVC && (this.enjoyPlaceVC = new t()),
          (this.enjoyPlaceVC.tab_enjoy.selectedIndex = 0),
          (this.enjoyPlaceVC.image_caicaiya.visible = !0),
          (this.enjoyPlaceVC.image_sanguoya.visible = !1),
          (this.enjoyPlaceVC.image_caiquanya.visible = !1),
          (this.enjoyPlaceVC.btn_historyRecord.label = "历史记录"),
          (this.enjoyPlaceVC.btn_bettingRecord.label = "投注记录"),
          (this.enjoyPlaceVC.btn_rewardList.label = "奖励排行"),
          (this.enjoyPlaceVC.btn_gameRule.label = "游戏规则"),
          WebSocketService.send({ c: 1332, d: null }),
          WebSocketService.send({ c: 1451, d: null }),
          (this.enjoyPlaceVC.closeRound = !0),
          this.enjoyPlaceVC
        );
      }),
      (t.prototype.showCountRoundView = function () {
        this.closeRound &&
          ((this.countRoundV = CountRoundView.openCountRoundView(
            this,
            this.hideCountRoundView
          )),
          (this.countRoundV.y = 150),
          Laya.stage.addChild(this.countRoundV));
      }),
      (t.prototype.hideCountRoundView = function () {
        (this.closeRound = !1), this.countRoundV && this.countRoundV.close();
      }),
      (t.prototype.onsupportDidClickFn = function (e) {
        "item0" == e.target.name
          ? GuessSizeFitView.openSanGuo("魏国", "1", "2")
          : "item1" == e.target.name
          ? GuessSizeFitView.openSanGuo("蜀国", "1", "2")
          : "item2" == e.target.name &&
            GuessSizeFitView.openSanGuo("吴国", "1", "2");
      }),
      (t.prototype.setCaiQuanSelected = function (e) {
        if ("jieshoutiaozhan" == e.target.name && this.caiquanArr.length) {
          var t = this.caiquanArr[this.list_caiquan.selectedIndex].userID;
          if (Global.roleId == t)
            return void ToastView.toastView("不可挑战自己");
          var i = this.caiquanArr[this.list_caiquan.selectedIndex].figID,
            n =
              this.caiquanArr[this.list_caiquan.selectedIndex].othName +
              "投入" +
              this.caiquanArr[this.list_caiquan.selectedIndex].figTitle +
              "银";
          GuessFigureView.open(i, n);
        }
      }),
      (t.prototype.onSelectEnjoyHandleFn = function (e) {
        (this.list_caiquan.visible = !1),
          0 == e
            ? ((this.image_caicaiya.visible = !0),
              (this.image_sanguoya.visible = !1),
              (this.image_caiquanya.visible = !1),
              (this.btn_ccywinnerList.visible = !0),
              (this.btn_historyRecord.label = "历史记录"),
              (this.btn_bettingRecord.label = "投注记录"),
              (this.btn_rewardList.label = "奖励排行"),
              (this.btn_gameRule.label = "游戏规则"))
            : 1 == e
            ? ((this.image_caicaiya.visible = !1),
              (this.image_sanguoya.visible = !0),
              (this.image_caiquanya.visible = !1),
              (this.btn_ccywinnerList.visible = !0),
              WebSocketService.send({ c: 4430, d: { pageNum: 0 } }),
              (this.btn_historyRecord.label = "历史记录"),
              (this.btn_bettingRecord.label = "支援记录"),
              (this.btn_rewardList.label = "奖励排行"),
              (this.btn_gameRule.label = "游戏规则"))
            : 2 == e &&
              ((this.image_caicaiya.visible = !1),
              (this.image_sanguoya.visible = !1),
              (this.image_caiquanya.visible = !0),
              (this.btn_ccywinnerList.visible = !1),
              WebSocketService.send({ c: 2103, d: { pageNum: 0 } }),
              (this.list_caiquan.selectEnable = !0),
              (this.btn_historyRecord.label = "挑战记录"),
              (this.btn_bettingRecord.label = "应战记录"),
              (this.btn_rewardList.label = "赢家排行"),
              (this.btn_gameRule.label = "赚币排行"),
              Laya.timer.loop(15e3, this, this.timerCouTimeCaiQuanFn));
      }),
      (t.prototype.timerCouTimeCaiQuanFn = function () {
        WebSocketService.send({ c: 2103, d: { pageNum: 0 } });
      }),
      (t.prototype.dealCaiquanReslutFn = function (e) {
        var t = "";
        return (
          "0" == e
            ? (t = "挑战")
            : "1" == e
            ? (t = "已胜利")
            : "2" == e
            ? (t = "已失败")
            : "3" == e
            ? (t = "战平")
            : "4" == e
            ? (t = "对方拒绝")
            : "5" == e && (t = "不存在"),
          t
        );
      }),
      (t.prototype.dealPerNumToBaGua = function (e) {
        var t = "";
        return (
          "1" == e
            ? (t = "乾")
            : "2" == e
            ? (t = "兑")
            : "3" == e
            ? (t = "离")
            : "4" == e
            ? (t = "震")
            : "5" == e
            ? (t = "坤")
            : "6" == e
            ? (t = "艮")
            : "7" == e
            ? (t = "坎")
            : "8" == e && (t = "巽"),
          t
        );
      }),
      (t.prototype.timerCountDownFn = function () {
        this.timeDiff--;
        var e = Math.floor(this.timeDiff / 60),
          t = Math.floor(this.timeDiff % 60);
        e <= 0 && t <= 1
          ? (Laya.timer.clear(this, this.timerCountDownFn),
            WebSocketService.send({ c: 1332, d: null }),
            (this.countdownLab.text = "正在开奖，请稍等..."))
          : t % 15 == 0
          ? (WebSocketService.send({ c: 1332, d: null }),
            (this.countdownLab.text =
              "还有" + e + "分" + t + "秒开，买定离手啦！"))
          : (this.countdownLab.text =
              "还有" + e + "分" + t + "秒开，买定离手啦！"),
          this.timeDiff <= 10
            ? this.showCountRoundView()
            : (this.closeRound = !0);
      }),
      (t.prototype.timerCountDownSanguoFn = function () {
        this.sanguoTimeDiff--;
        var e = Math.floor(this.sanguoTimeDiff / 60),
          t = this.sanguoTimeDiff % 60;
        e <= 0 && t <= 1
          ? (this.lbl_sanguodjs.text = "正在开奖，请稍等...")
          : this.sanguoTimeDiff >= 599
          ? (Laya.timer.clear(this, this.timerCountDownSanguoFn),
            WebSocketService.send({ c: 4430, d: null }))
          : (this.lbl_sanguodjs.text =
              "还有" + e + "分" + t + "秒决出胜负，请求支援"),
          this.sanguoTimeDiff % 15 == 0 &&
            (Laya.timer.clear(this, this.timerCountDownSanguoFn),
            WebSocketService.send({ c: 4430, d: null }));
      }),
      (t.prototype.onBigDidClick = function () {
        GuessSizeFitView.open("太", "3", "4");
      }),
      (t.prototype.onSmallDidClick = function () {
        GuessSizeFitView.open("少", "1", "2");
      }),
      (t.prototype.onSingleDidClick = function () {
        GuessSizeFitView.open("阴", "7", "8");
      }),
      (t.prototype.onDoubleDidClick = function () {
        GuessSizeFitView.open("阳", "9", "10");
      }),
      (t.prototype.onLeopardDidClick = function () {
        GuessSizeFitView.open("上上签", "5", "6");
      }),
      (t.prototype.onShangQianDidClick = function () {
        GuessSizeFitView.open("上签", "11", "12");
      }),
      (t.prototype.initCaiCaiDesktopView = function (e) {
        (this.lbl_big_totalgold.text = e.sumdagold + "金"),
          (this.lbl_big_totalsliver.text = e.sumdasliver + "银"),
          (this.lbl_big_mygold.text = "0 金"),
          (this.lbl_big_mysliver.text = "0 银"),
          (this.lbl_small_totalgold.text = e.sumxiaogold + "金"),
          (this.lbl_small_totalsliver.text = e.sumxiaosliver + "银"),
          (this.lbl_small_mygold.text = "0 金"),
          (this.lbl_small_mysliver.text = "0 银"),
          (this.lbl_signal_totalgold.text = e.sumdangold + "金"),
          (this.lbl_signal_totalsliver.text = e.sumdansliver + "银"),
          (this.lbl_signal_mygold.text = "0 金"),
          (this.lbl_signal_mysliver.text = "0 银"),
          (this.lbl_double_totalgold.text = e.sumshuanggold + "金"),
          (this.lbl_double_totalsliver.text = e.sumshuangsliver + "银"),
          (this.lbl_double_mygold.text = "0 金"),
          (this.lbl_double_mysliver.text = "0 银"),
          (this.lbl_leopard_totalgold.text = e.sumbaozigold + "金"),
          (this.lbl_leopard_totalsliver.text = e.sumbaozisliver + "银"),
          (this.lbl_leopard_mygold.text = "0 金"),
          (this.lbl_leopard_mysliver.text = "0 银"),
          (this.lbl_shangqian_totalgold.text = e.sumonepairgold + "金"),
          (this.lbl_shangqian_totalsliver.text = e.sumonepairsliver + "银"),
          (this.lbl_shangqian_mygold.text = "0 金"),
          (this.lbl_shangqian_mysliver.text = "0 银");
        for (var t = e.list, i = 0; i < t.length; i++) {
          var n = t[i].type,
            a = t[i].gold,
            o = t[i].sliver;
          "1" == n
            ? ((this.lbl_small_mygold.text = a + " 金"),
              (this.lbl_small_mysliver.text = o + " 银"))
            : "3" == n
            ? ((this.lbl_big_mygold.text = a + " 金"),
              (this.lbl_big_mysliver.text = o + " 银"))
            : "5" == n
            ? ((this.lbl_leopard_mygold.text = a + " 金"),
              (this.lbl_leopard_mysliver.text = o + " 银"))
            : "7" == n
            ? ((this.lbl_signal_mygold.text = a + " 金"),
              (this.lbl_signal_mysliver.text = o + " 银"))
            : "9" == n
            ? ((this.lbl_double_mygold.text = a + " 金"),
              (this.lbl_double_mysliver.text = o + " 银"))
            : "11" == n &&
              ((this.lbl_shangqian_mygold.text = a + " 金"),
              (this.lbl_shangqian_mysliver.text = o + " 银"));
        }
      }),
      (t.prototype.initSanGuoDesktopView = function (e) {
        for (var t = e.list, i = 0; i < t.length; i++) {
          var n = t[i].side,
            a = t[i].gold,
            o = t[i].sliver;
          1 == n
            ? ((this.lbl_wei_sumgold.text = a + " 金"),
              (this.lbl_wei_sumsliver.text = o + " 银"))
            : 2 == n
            ? ((this.lbl_shu_sumgold.text = a + " 金"),
              (this.lbl_shu_sumsliver.text = o + " 银"))
            : 3 == n &&
              ((this.lbl_wu_sumgold.text = a + " 金"),
              (this.lbl_wu_sumsliver.text = o + " 银"));
        }
        var l = [];
        e.myList && (l = e.myList);
        for (i = 0; i < l.length; i++) {
          var n = l[i].side,
            a = l[i].gold,
            o = l[i].sliver;
          1 == n
            ? ((this.lbl_wei_mygold.text = a + " 金"),
              (this.lbl_wei_mysliver.text = o + " 银"))
            : 2 == n
            ? ((this.lbl_shu_mygold.text = a + " 金"),
              (this.lbl_shu_mysliver.text = o + " 银"))
            : 3 == n &&
              ((this.lbl_wu_mygold.text = a + " 金"),
              (this.lbl_wu_mysliver.text = o + " 银"));
        }
      }),
      (t.prototype.onThrowChallengeFn = function () {
        GuessPapersView.showCaiQuanDialog();
      }),
      (t.prototype.onEnjoyCommonDidClickFn = function (e) {
        if (0 == this.tab_enjoy.selectedIndex)
          if ("item0" == e.target.name) {
            ((i = AXEnjoyHistoryView.openView("1")).y = 35),
              Laya.stage.addChild(i);
          } else if ("item1" == e.target.name) {
            ((i = AXEnjoyHistoryView.openView("2")).y = 35),
              Laya.stage.addChild(i);
          } else if ("item2" == e.target.name) {
            ((i = AXEnjoyHistoryView.openView("3")).y = 35),
              Laya.stage.addChild(i);
          } else if ("item3" == e.target.name) {
            ((t = CaslnoRulesView.showCaslRuleView("caicaiya")).y = 35),
              Laya.stage.addChild(t);
          } else "item4" == e.target.name && AXEnjoyResultView.openView(1);
        else if (1 == this.tab_enjoy.selectedIndex)
          if ("item0" == e.target.name) {
            ((i = AXEnjoyHistoryView.openView("4")).y = 35),
              Laya.stage.addChild(i);
          } else if ("item1" == e.target.name) {
            ((i = AXEnjoyHistoryView.openView("5")).y = 35),
              Laya.stage.addChild(i);
          } else if ("item2" == e.target.name) {
            ((i = AXEnjoyHistoryView.openView("3")).y = 35),
              Laya.stage.addChild(i);
          } else if ("item3" == e.target.name) {
            var t = CaslnoRulesView.showCaslRuleView("samguoya");
            (t.y = 35), Laya.stage.addChild(t);
          } else "item4" == e.target.name && AXEnjoyResultView.openView(2);
        else if (2 == this.tab_enjoy.selectedIndex)
          if ("item0" == e.target.name) {
            ((i = AXEnjoyHistoryView.openView("6")).y = 35),
              Laya.stage.addChild(i);
          } else if ("item1" == e.target.name) {
            ((i = AXEnjoyHistoryView.openView("7")).y = 35),
              Laya.stage.addChild(i);
          } else if ("item2" == e.target.name) {
            ((i = AXEnjoyHistoryView.openView("8")).y = 35),
              Laya.stage.addChild(i);
          } else if ("item3" == e.target.name) {
            var i = AXEnjoyHistoryView.openView("9");
            (i.y = 35), Laya.stage.addChild(i);
          }
      }),
      (t.prototype.dealCaiQuanYaMoneryCell = function (e) {
        return "1" == e ? "金" : "银";
      }),
      (t.prototype.onPoChanShenQingFn = function () {
        CommanTwoItemDialog.showCommonDialog();
      }),
      (t.prototype.onEnjoyPlaceBackFn = function () {
        Laya.timer.clear(this, this.timerCountDownFn),
          Laya.timer.clear(this, this.timerCountDownSanguoFn),
          Laya.timer.clear(this, this.timerCouTimeCaiQuanFn),
          Laya.timer.clearAll(this),
          this.hideCountRoundView(),
          this.removeSelf();
      }),
      t
    );
  })(ui.SquareController.AXEnjoyPlaceViewUI);
